home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / gateway.idb / usr / WebFace / Source / 20-NetworkServices / nfs / nfs-mount.frm.z / nfs-mount.frm
Encoding:
Text File  |  1997-07-30  |  21.7 KB  |  696 lines

  1. #!/usr/bin/perl5
  2.  
  3. # nfs-mount.cgi
  4.  
  5. # notes: \ at end of line to continue not supported.
  6. # (this is supported for nfs-export)
  7.  
  8. require "/usr/OnRamp/lib/OnRamp.pm";
  9. require "/usr/OnRamp/lib/java.pm";
  10.  
  11. $myname = "nfs-mount.cgi";
  12. $title = "Filesystem Configuration";
  13. $conf = "/etc/fstab";
  14. $temp = "/etc/fstab.tmp";
  15.  
  16. $account_type_uc = "Filesystem";
  17. $account_type_lc = "filesystem";
  18.  
  19. $js_main =
  20. "type = \"filesystem\";
  21. $js_account_main
  22. $js_error_box
  23. $js_filename
  24. $js_hostname
  25. function testFilesystem(form, Ctrl, what) {
  26.     colon = Ctrl.value.indexOf(':', 0);
  27.     if (colon < 0) {
  28.         if (!testFilename(Ctrl, what)) return (false);
  29.     } else {
  30.         host = Ctrl.value.substring(0, colon);
  31.         file = Ctrl.value.substring(colon + 1);
  32.         if (!testHostname(Ctrl, host, what, 0)) return (false);
  33.         if (!testThisFilename(form.edit, file, what)) return (false);
  34.     }
  35.     return (true);
  36. }
  37. function testThisFilename(Ctrl, word, what) {
  38.         if (word == \"\") {
  39.                 errorBox (Ctrl, \"The \" + what + \" is required.\");
  40.                 return (false);
  41.         }
  42.         if (!testFileChars(word)) {
  43.                 errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain \"
  44.                         + illegal + \" characters.\");
  45.                 return (false);
  46.         }
  47.         for(i = 0; i < word.length; i++) {
  48.                 if (word.charAt(i) == ' ') {
  49.                         errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain spaces.\");
  50.                         return (false);
  51.                 }
  52.         }
  53.         if (word.charAt(0) != '/') {
  54.                 errorBox (Ctrl, \"The \" + what + \" must be fully qualified.\");
  55.                 return (false);
  56.         }
  57.         return (true);
  58. }
  59. function testFileChars(word) {
  60.         metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\";
  61.         for(j = 0; j < metaChars.length; j++) {
  62.                 illegal = metaChars.charAt(j);
  63.                 if (word.indexOf (illegal, 0) != -1) return (false);
  64.         } return (true);
  65. }
  66. function testAdd(form) {
  67.     if (form.new_account.value == \"\") {
  68.         errorBox (form.new_account, \"To add an existing \" + type + \", \"
  69.             + \"first enter a \" + type + \"\\n\"
  70.             + \"then click the add button.\");
  71.         return (false);
  72.     }
  73.     if (!testFilesystem(form, form.new_account, \"filesystem\")) return (false);
  74.     return (true);
  75. }";
  76.  
  77. $js_edit =
  78. "$js_standard
  79. $js_error_box
  80. $js_filename
  81. function checkForm(form)  {
  82.     if (!testFilename(form.dir, \"mount directory\")) return (false);
  83.     return (true);
  84. }";
  85.  
  86. $js_options =
  87. "$js_check_int
  88. $js_standard
  89. $js_error_box
  90. $js_filename
  91. function testNumber(Ctrl, what) {
  92.     if (Ctrl.value == \"\") return (true);
  93.     if (! checkInt(Ctrl.value, 10)) {
  94.         errorBox(Ctrl, \"The \" + what + \" entered is not a number.\");
  95.         return (false);
  96.     }
  97.     return (true);
  98. }
  99. function testVersion(Ctrl, what) {
  100.     if (Ctrl.value == \"\") return (true);
  101.     if (Ctrl.value != \"2\" && Ctrl.value != \"3\") {
  102.         errorBox(Ctrl, \"The \" + what + \" must be 2 or 3.\");
  103.         return (false);
  104.     }
  105.     return (true);
  106. }
  107. function testPortNo(Ctrl, what) {
  108.     if (Ctrl.value == \"\") return (true);
  109.     num = parseInt(Ctrl.value);
  110.     if ((! checkInt(Ctrl.value, 10)) || num < 0 || num > 65536) {
  111.         errorBox(Ctrl, \"The \" + what + \" must be a number between 0 and 65,535\");
  112.         return (false);
  113.     }
  114.     return (true);
  115. }
  116. function testPriority(Ctrl, what) {
  117.     if (Ctrl.value == \"\") return (true);
  118.     num = parseInt(Ctrl.value);
  119.     if ((! checkInt(Ctrl.value, 10)) || num < 0 || num > 7) {
  120.         errorBox(Ctrl, \"The \" + what + \" must be a number between 0 and 7\");
  121.         return (false);
  122.     }
  123.     return (true);
  124. }
  125. function testFile(Ctrl, what) {
  126.     if (Ctrl.value == \"\") return (true);
  127.     if (!testFilename(Ctrl, what)) return (false);
  128.     return (true);
  129. }
  130. function checkForm(form)  {
  131.     type = form.type.value;
  132.     if (type != \"swap\" && type != \"cachefs\") {
  133.         if (!testFile(form.raw, \"raw device pathname\")) return (false);
  134.         if (!testNumber(form.lbsize, \"transfer bytes\")) return (false);
  135.     }
  136.     if (type == \"iso9660\") {
  137.         if (!testNumber(form.cache, \"caching blocks\")) return (false);
  138.     }
  139.     if (type == \"iso9660\" || type == \"hfs\") {
  140.         if (!testNumber(form.partition, \"DOS partition\")) return (false);
  141.     }
  142.     if (type == \"nfs\") {
  143.         if (!testVersion(form.vers, \"NFS version\")) return (false);
  144.         if (!testNumber(form.retry, \"mount retry times\")) return (false);
  145.         if (!testNumber(form.rsize, \"read buffer size\")) return (false);
  146.         if (!testNumber(form.wsize, \"write buffer size\")) return (false);
  147.         if (!testNumber(form.timeo, \"NFS timeout\")) return (false);
  148.         if (!testNumber(form.retrans, \"NFS retransmissions\")) return (false);
  149.         if (!testPortNo(form.port, \"UDP port number\")) return (false);
  150.         if (!testNumber(form.symttl, \"time-to-live\")) return (false);
  151.     }
  152.     if (type == \"nfs\" || type == \"cachefs\") {
  153.         if (!testNumber(form.acregmin, \"cache timeout\")) return (false);
  154.         if (!testNumber(form.acregmax, \"cache timeout\")) return (false);
  155.         if (!testNumber(form.acdirmin, \"cache timeout\")) return (false);
  156.         if (!testNumber(form.acdirmax, \"cache timeout\")) return (false);
  157.         if (!testNumber(form.actimeo, \"cache timeout\")) return (false);
  158.     }
  159.     if (type == \"swap\") {
  160.         if (!testPriority(form.pri, \"priority\")) return (false);
  161.         if (!testNumber(form.swplo, \"starting block\")) return (false);
  162.         if (!testNumber(form.slength, \"swap size\")) return (false);
  163.         if (!testNumber(form.maxlength, \"maximum swap size\")) return (false);
  164.         if (!testNumber(form.vlength, \"virtual length\")) return (false);
  165.     }
  166.     if (type == \"cachefs\") {
  167.         if (!testFile(form.backpath, \"mount point\")) return (false);
  168.         if (!testFile(form.cachedir, \"cache directory\")) return (false);
  169.     }
  170.     
  171.     return (true);
  172. }";
  173.  
  174.  
  175. print "Content-type: text/html\n\n";
  176.  
  177. &get_fields;
  178.  
  179. &getAccounts;
  180.  
  181. if (%fld) {
  182.     $fld{'chosen'} =~ /([\w.-\/:]+)/;
  183.     $name = $1;
  184.  
  185.     $help = $document_root . $ENV{"SCRIPT_NAME"};
  186.     $help =~ s/cgi$/hlp/;
  187.     exec $help if ($fld{'help'} eq "Help");
  188.  
  189.     if ($fld{'options'} eq "Options") {
  190.         &make_options;
  191.     }
  192.     if ($fld{'add'}) {
  193.         $name = $fld{'new_account'};
  194.         $ttl = "Add Filesystem";
  195.         &editAccount;
  196.     }
  197.     if ($fld{'edit'} || $fld{'get_options'}) { 
  198.         if ($fld{'edit'}) { &get_vals($name); }
  199.         else {
  200.             $val{'dir'} = $fld{'dir'};
  201.             $val{'type'} = $fld{'type'};
  202.             $name = $fld{'chosen'};
  203.  
  204.             $val{'opt_string'} = &create_opt_string;
  205.  
  206.             $message .= "Click \"Ok\" to save changes.";
  207.         }
  208.         $ttl = "Edit Filesystem";
  209.         &editAccount; 
  210.         exit 0;
  211.     }
  212.     if ($fld{'ok'}) { 
  213.         &doEdit; 
  214.         &getAccounts; 
  215.         &generic; 
  216.     }
  217.     if ($fld{'delete'}) {
  218.         $message = qq|Click "Ok" to save changes.|;
  219.         $delete = 1;
  220.         &generic;
  221.     }
  222.     if ($fld{'doit'}) {
  223.         if ($fld{'delFile'}) { 
  224.             &delete($fld{'delFile'}); 
  225.             &getAccounts;
  226.         }
  227.         &generic;
  228.     }
  229. } else { &generic; }
  230.  
  231. sub delete {
  232.     open(IN, "< $conf");
  233.     open(OUT, "> $temp");
  234.     while(<IN>) {
  235.         @items = split(/\s+/);
  236.         if ($items[0] ne $_[0]) { print OUT $_; }
  237.     }
  238.     close(IN);
  239.     close(OUT);
  240.  
  241.     rename($temp, $conf);
  242.  
  243.     $message .= "Entry deleted.";
  244. }
  245.  
  246. sub doEdit {
  247.     $new_line = "$fld{'chosen'} $fld{'dir'} $fld{'type'} $fld{'opt_string'} 0 0";
  248.  
  249.     if ($fld{'mode'} eq "add") {
  250.         open(OUT, ">> $conf");
  251.         print OUT "$new_line\n";
  252.         close(OUT);
  253.  
  254.         $message .= "Entry added.";
  255.     } else {
  256.         open(IN, "< $conf");
  257.         open(OUT, "> $temp");
  258.         while(<IN>) {
  259.             @items = split(/\s+/);
  260.             if ($items[0] eq $fld{'chosen'}) { 
  261.                 print OUT "$new_line\n";
  262.             } else { print OUT $_; }
  263.         }
  264.         close(IN);
  265.         close(OUT);
  266.  
  267.         rename($temp, $conf);
  268.  
  269.         $message .= "Entry edited.";
  270.     }
  271. }
  272.  
  273. sub get_vals {
  274.     for($i=0; $i<=$#accounts; $i++) {
  275.         if ($accounts[$i] eq $_[0]) {
  276.             $val{'dir'} = $dir[$i];
  277.             $val{'type'} = $type[$i];
  278.             $val{'opt_string'} = $opt_string[$i];
  279.         }
  280.     }
  281. }    
  282.  
  283. sub create_opt_string {
  284.     &get_options;
  285.     &get_defs;
  286.  
  287.     undef (@opts);
  288.     
  289.     if ($fld{'ro'} eq "No") { push(@opts, "rw"); }
  290.  
  291.     if ($fld{'type'} ne 'swap' && $fld{'type'} ne 'cachefs') { &add_opts(*st_opt); }
  292.  
  293.     if ($fld{'type'} eq 'iso9660') { &add_opts(*iso_opt); }
  294.     elsif ($fld{'type'} eq 'hfs') { &add_opts(*hfs_opt); }
  295.     elsif ($fld{'type'} eq 'nfs') { &add_opts(*nfs_opt); }
  296.     elsif ($fld{'type'} eq 'cachefs') { &add_opts(*cache_opt); }
  297.     elsif ($fld{'type'} eq 'swap') { &add_opts(*swap_opt); }
  298.  
  299.     return join(',', @opts);
  300. }
  301.  
  302. sub add_opts {
  303.     local(*lst) = $_[0];
  304.  
  305.     for ($i=0; $i<$#lst; $i+=3) {
  306.         next if $fld{$lst[$i]} eq $def{$lst[$i]};
  307.         if ($lst[$i+1] eq 'r') { push(@opts, $lst[$i]); }
  308.         elsif ($lst[$i] eq "slength") { push(@opts, "length=$fld{$lst[$i]}"); }
  309.         elsif ($lst[$i+1] eq 't') { 
  310.             push(@opts, "$lst[$i]=$fld{$lst[$i]}") if $fld{$lst[$i]}; 
  311.         } else {
  312.             if ($lst[$i] eq 'nmconv') {
  313.                 undef ($ch);
  314.                 $ch = "c" if $fld{'nmconv'} eq "Don't translate to UNIX";
  315.                 $ch = "l" if $fld{'nmconv'} eq "Translate to lower case";
  316.                 $ch = "m" if $fld{'nmconv'} eq "Suppress version number";
  317.             
  318.                 if ($ch) { push(@opts, "nmconv=$ch"); }
  319.             } elsif ($lst[$i] eq 'backfstype') {
  320.                 push(@opts, "$lst[$i]=$fld{$lst[$i]}");
  321.             } elsif ($lst[$i] eq 'write-around') {
  322.                 push(@opts, "write-around");
  323.             }
  324.         }
  325.     }
  326. }
  327.  
  328. sub get_defs {
  329.     for ($i=0; $i<$#st_opt; $i+=3) { 
  330.         if ($st_opt[$i+1] eq 'r') { $def{$st_opt[$i]} = "No"; }
  331.     }
  332.     for ($i=0; $i<$#iso_opt; $i+=3) {
  333.         if ($iso_opt[$i+1] eq 'r') { $def{$iso_opt[$i]} = "No"; }
  334.     }
  335.     for ($i=0; $i<$#nfs_opt; $i+=3) {
  336.         if ($nfs_opt[$i+1] eq 'r') { $def{$nfs_opt[$i]} = "No"; }
  337.     }
  338.  
  339.     $def{'partition'} = 1;
  340.     $def{'cache'} = 128;
  341.     $def{'retry'} = 10000;
  342.     $def{'rsize'} = 8096;
  343.     $def{'wsize'} = 8096;
  344.     $def{'timeo'} = 11;
  345.     $def{'retrans'} = 5;
  346.     $def{'port'} = 2049;
  347.     $def{'hard'} = "Yes";
  348.     $def{'acregmin'} = 3;
  349.     $def{'acregmax'} = 60;
  350.     $def{'acdirmin'} = 30;
  351.     $def{'acdirmax'} = 60;
  352.     $def{'symttl'} = 3600;    
  353.  
  354.     $def{'swplo'} = 0;
  355.  
  356.     if ($fld{'type'} eq "cachefs") {
  357.         $def{'actimeo'} = 30;
  358.     }
  359.  
  360.     $def{'nmconv'} = "None";
  361.     $def{'backfstype'} = "default";
  362.     $def{'write-around'} = "non-shared";
  363.     
  364.  
  365. }
  366.  
  367. sub get_options {
  368.     @st_opt =     (    'ro',         'r',    'Mount read-only?',
  369.             'noauto',     'r',    'Ignore during "mount -a" command?',
  370.             'grpid',     'r',    'Set group id to group id of parent directory?',
  371.             'nosuid',    'r',    'Setuid execution not allowed for non-superusers?',
  372.             'nodev',    'r',    'Deny access to character and block special files?',
  373.             'dmi',        'r',    'Enable the Data Management Interface event callouts?',
  374.             'raw',        't',    'Raw device pathname:',
  375.             'fsck',        'r',    'Check this filesystem when "fsck" invoked with no arguments?',
  376.             'nofsck',    'r',    'Have "fsck" not check this filesystem by default?',
  377.             'quota',    'r',    'Enforce disk quotas?',
  378.             'noquota',    'r',    'Do not enforce disk quotas?',
  379.             'lbsize',    't',    'Number of bytes to transfer in each read or synchronous '
  380.                             . 'write operation:'
  381.               );
  382.  
  383.     @iso_opt =    (    'setx',        'r',    'Set execute permission on all files?',
  384.             'notranslate',    'r',    'Don\'t translate ISO 9660 filenames to UNIX filenames?',
  385.             'cache',    't',    'Number of 2048 byte blocks used for caching:',
  386.             'noext',    'r',    'Ignore Rock Ridge extensions?',
  387.             'susp',        'r',    'Enable processing of System Use Sharing Protocol?',
  388.             'nosusp',    'r',    'Disable processing of System Use Sharing Protocol?',
  389.             'rrip',        'r',    'Enable processing of the Rock Ridge extensions?',
  390.             'norrip',    'r',    'Disable processing of the Rock Ridge extensions?',
  391.             'nmconv',    's',    'Filename translation control:',
  392.             'partition',    't',    'Number of DOS partition to mount:'
  393.               );
  394.  
  395.  
  396.     @hfs_opt =    ( 'partition',    't',    'Number of DOS partition to mount:' );
  397.  
  398.     @nfs_opt =    (    'vers',        't',    'NFS protocol version:',
  399.             'bg',        'r',    'If the first mount attempt fails, retry in the background?',
  400.             'retry',    't',    'Number of times to retry mount in case of failure:',
  401.             'rsize',    't',    'Read buffer size:',
  402.             'wsize',    't',    'Write buffer size:',
  403.             'timeo',    't',    'NFS timeout in tenths of seconds:',
  404.             'retrans',    't',    'NFS retransmissions:',
  405.             'port',        't',    'Server UDP port number:',
  406.             'hard',        'r',    'Retry request until server responds?',
  407.             'soft',        'r',    'Return error if server doesn\'t respond?',
  408.             'intr',        'r',    'Allow signal interrupts of accesses?',
  409.             'acregmin',    't',    'Cache timeout of regular file minimum attribute in seconds:',
  410.             'acregmax',    't',    'Cache timeout of regular file maximum attribute in seconds:',
  411.             'acdirmin',    't',    'Cache timeout of directory minimum attribute in seconds:',
  412.             'acdirmax',    't',    'Cache timeout of directory maximum attribute in seconds:',
  413.             'actimeo',    't',    'Cache timeout of regular and directory minimum and maximum '
  414.                             . 'attribute in seconds:',
  415.             'noac',        'r',    'No attribute caching?',
  416.             'private',    'r',    'Do not flush delayed writes on last close of an open file, '
  417.                             . 'and use local file and record locking instead of '
  418.                             . 'a remote lock manager?',
  419.             'shortuid',    'r',    'Do not let users with userids or groupids larger than 65535 '
  420.                             . 'create or own files?',
  421.             'symttl',    't',    'Time-to-live of symbolic links cached by NFS',
  422.             'asyncnlm',    'r',    'Use asynchronous NLM RPC calls?'
  423.               );
  424.  
  425.     @swap_opt =   ( 'noauto',    'r',    'Ignore during "mount -a" command?',
  426.             'pri',        't',    'Priority level of swap device:',
  427.             'swplo',    't',    'Starting 512 byte block:',
  428.             'slength',    't',     'Number of 512 byte blocks to use:',
  429.             'maxlength',    't',    'Maximum number of 512 byte blocks to grow swap area to:',
  430.             'vlength',    't',    'Number of virtual 512 byte blocks to claim this swap area has:'
  431.               ); 
  432.  
  433.     @cache_opt =  ( 'backfstype',    's',    'Filesystem type of back filesystem:',
  434.             'backpath',     't',    'Point where back filesystem is already mounted:',
  435.             'cachedir',    't',    'Name of cache directory:',
  436.             'cacheid',    't',    'Cache ID string:',
  437.             'write-around',    's',    'Write mode for cache filesystem:',
  438.             'noconst',    'r',    'Disable consistency checking?',
  439.             'private',    'r',    'Perform file and record locking locally?',
  440.             'local-access',    'r',    'Allow front filesystem to interpret the mode bits used for '
  441.                             . 'access checking?',
  442.             'purge',    'r',    'Purge cached information for filesystem?',
  443.             'nosuid',    'r',    'Disallow set-uid execution?',
  444.             'acregmin',     't',    'Minimum hold time for cached attributes:',
  445.             'acregmax',    't',    'Maximum hold time for cached attributes:', 
  446.             'acdirmin',    't',    'Minimum hold time for cached attributes after directory update:',
  447.             'acdirmax',    't',    'Maximum hold time for cached attributes after directory update:',
  448.             'actimeo',    't',    'Common value for above four caching times:',
  449.             'bg',        'r',    'Run mount in background if back filesystem mount times out?',
  450.             'disconnect',    'r',    'Operate cache filesystem in disconnected mode when the '
  451.                             . 'back filesystem fails to respond?'
  452.               );
  453. }
  454.  
  455. sub read_opts {
  456.     open(IN, "< $conf");
  457.     while(<IN>) {
  458.         @items = split(/\s+/);
  459.         if ($items[0] eq $_[0]) {
  460.             @opts = split(/,/, $items[3]);
  461.             foreach (@opts) {
  462.                 if ($_ =~ /^(.*)=(.*)$/) { 
  463.                     if ($1 eq "nmconv") { 
  464.                         $val{'nmconv'} = "Don't translate to UNIX" if $2 eq "c";
  465.                         $val{'nmconv'} = "Translate to lower case" if $2 eq "l";
  466.                         $val{'nmconv'} = "Suppress version number" if $2 eq "m";
  467.                     } else { $val{$1} = $2; }
  468.                 } else { $val{$_} = "Yes"; }
  469.             }
  470.         }
  471.     }
  472.     close(IN);
  473. }
  474.  
  475. sub make_options {
  476.     &get_options;
  477.     &get_defs;
  478.     %val = %def;
  479.     &read_opts($fld{'chosen'});
  480.  
  481.     &js_title_block($title,$js_options);
  482.     &header_block("Options for $fld{'type'}");
  483.  
  484.     print "<form name=StandardForm action=$myname method=post onSubmit=\"return runSubmit()\">";
  485.  
  486.     print "<input type=hidden name=\"get_options\" value=\"get_options\">\n";
  487.     print "<input type=hidden name=\"chosen\" value=$fld{'chosen'}>\n";
  488.     print "<input type=hidden name=\"dir\" value=$fld{'dir'}>\n";
  489.     print "<input type=hidden name=\"type\" value=$fld{'type'}>\n";
  490.     print qq|<input type=hidden name="mode" value=$fld{'mode'}>|;
  491.  
  492.     if ($fld{'type'} ne 'swap' && $fld{'type'} ne 'cachefs') {
  493.  
  494.         print "<h2>Standard Options:</h2>\n";
  495.         print "<center><table cellpadding=5 width=450>";
  496.  
  497.         for($i=0; $i<$#st_opt; $i+=3) {
  498.             print "<tr><th align=left>$st_opt[$i+2]</th><th align=left>";
  499.             if ($st_opt[$i+1] eq 'r') { print &radio($st_opt[$i], $val{$st_opt[$i]}, "Yes", "No"); }
  500.             elsif ($st_opt[$i+1] eq 't') { print &text($st_opt[$i], $val{$st_opt[$i]}, 20); }
  501.             else { ; }
  502.             print "</th></tr>\n";
  503.         }
  504.  
  505.         print "</table></center><br>";
  506.     }
  507.  
  508.     if ($fld{'type'} eq 'iso9660') {
  509.  
  510.         print "<h2>ISO9660 Options:</h2>\n";
  511.         print "<center><table cellpadding=5 width=450>";
  512.         
  513.         for($i=0; $i<$#iso_opt; $i+=3) {
  514.             print "<tr><th align=left>$iso_opt[$i+2]</th><th align=left>";
  515.             if ($iso_opt[$i+1] eq 'r') { print &radio($iso_opt[$i], $val{$iso_opt[$i]}, "Yes", "No"); }
  516.             elsif ($iso_opt[$i+1] eq 't') { print &text($iso_opt[$i], $val{$iso_opt[$i]}, 20); }
  517.             else { print &select($iso_opt[$i], $val{$iso_opt[$i]}, "None", "Don't translate to UNIX",
  518.                         "Translate to lower case", "Suppress version number"); }
  519.             print "</th></tr>\n";
  520.         }
  521.  
  522.         print "</table></center><br>";
  523.  
  524.     } elsif ($fld{'type'} eq 'hfs') {
  525.  
  526.         print "<h2>HFS Options:</h2>\n";
  527.         print "<center><table cellpadding=5 width=450>";
  528.  
  529.         print "<tr><th align=left>Number of DOS partition to mount:</th><th align=left>";
  530.         print &text("partition", $val{'partition'}, 20);
  531.         print "</th></tr>\n";
  532.  
  533.         print "</table></center><br>";
  534.  
  535.     } elsif ($fld{'type'} eq 'nfs') {
  536.  
  537.         print "<h2>NFS Options:</h2>\n";
  538.         print "<center><table cellpadding=5 width=450>";
  539.  
  540.         for($i=0; $i<$#nfs_opt; $i+=3) {
  541.             print "<tr><th align=left>$nfs_opt[$i+2]</th><th align=left>";
  542.             if ($nfs_opt[$i+1] eq 'r') { print &radio($nfs_opt[$i], $val{$nfs_opt[$i]}, "Yes", "No"); }
  543.             elsif ($nfs_opt[$i+1] eq 't') { print &text($nfs_opt[$i], $val{$nfs_opt[$i]}, 20); }
  544.             else { ; }
  545.             print "</th></tr>\n";
  546.         }
  547.  
  548.         print "</table></center><br>";
  549.  
  550.     } elsif ($fld{'type'} eq 'swap') {
  551.  
  552.         print "<h2>Swap Options:</h2>\n";
  553.         print "<center><table cellpadding=5 width=450>";
  554.  
  555.         for($i=0; $i<$#swap_opt; $i+=3) {
  556.             print "<tr><th align=left>$swap_opt[$i+2]</th><th align=left>";
  557.             if ($swap_opt[$i+1] eq 'r') { print &radio($swap_opt[$i], $val{$swap_opt[$i]}, "Yes", "No"); }
  558.             elsif ($swap_opt[$i+1] eq 't') { print &text($swap_opt[$i], $val{$swap_opt[$i]}, 20); }
  559.             else { ; }
  560.             print "</th></tr>\n";
  561.         }
  562.  
  563.         print "</table></center><br>";
  564.  
  565.     } elsif ($fld{'type'} eq 'cachefs') {
  566.  
  567.         print "<h2>Cachefs Options:</h2>\n";
  568.         print "<center><table cellpadding=5 width=450>";
  569.  
  570.         for($i=0; $i<$#cache_opt; $i+=3) {
  571.             print "<tr><th align=left>$cache_opt[$i+2]</th><th align=left>";
  572.             if ($cache_opt[$i+1] eq 'r') { print &radio($cache_opt[$i], 
  573.                             $val{$cache_opt[$i]}, "Yes", "No"); }
  574.             elsif ($cache_opt[$i+1] eq 't') { print &text($cache_opt[$i], $val{$cache_opt[$i]}, 20); }
  575.             elsif ($cache_opt[$i] eq "backfstype") {
  576.                 print &select($cache_opt[$i], $val{$cache_opt[$i]}, "default", "nfs", "nfs3",
  577.                         "iso9660", "dos", "cdfs", "kfs", "hfs");
  578.             } else {
  579.                 print &select($cache_opt[$i], $val{$cache_opt[$i]}, 
  580.                         "write-arount", "non-shared");
  581.             }
  582.             print "</th></tr>\n";
  583.         }
  584.  
  585.         print "</table></center><br>";
  586.     }
  587.  
  588.     print &js_buttons('ok','Ok','onClick="markOK()"','onClick="markOther()"');
  589.  
  590.     print "</form></body></html>";
  591. }
  592.     
  593.  
  594. sub editAccount {
  595.     &js_title_block($title,$js_edit);
  596.     &header_block($ttl);
  597.  
  598.     print "<i>$message</i>\n";
  599.  
  600.     print "<form name=StandardForm action=$myname method=post onSubmit=\"return runSubmit()\">";
  601.  
  602.     print qq|<input type=hidden name="chosen" value=$name>|;
  603.     if ($fld{'add'}) { $mode = "add"; } else { $mode = "edit"; }
  604.     $mode = $fld{'mode'} if $fld{'mode'};
  605.     print qq|<input type=hidden name="mode" value=$mode>|;
  606.     print qq|<input type=hidden name="opt_string" value=$val{'opt_string'}>\n|;
  607.  
  608.     print "<center><table cellpadding=5 width=450>";
  609.  
  610.     print "<tr><th align=left>Filesystem:</th><th align=left>$name</th></tr>";
  611.  
  612.     print "<tr><th align=left>Mount directory:</th><th align=left>",
  613.         &text('dir', $val{'dir'}, 20),
  614.         "</th></tr>\n";
  615.  
  616.     print "<tr><th align=left>Filesystem type:</th><th align=left>",
  617.         &select('type', $val{'type'}, 'xfs', 'efs', 'nfs', 'proc', 'fd',
  618.                 'cdfs', 'iso9660', 'cdda', 'dos', 'hfs', 'swap',
  619.                 'cachefs', 'rawdata'),
  620.         "</th></tr>\n";
  621.  
  622.     print "<tr><th align=left>Set Advanced Options:</th><th align=left>",
  623.         "<input type=submit name=\"options\" value=\"Options\">",
  624.         "</th></tr>";
  625.  
  626.     print "</table></center><br>";
  627.  
  628.     print &js_buttons('ok','Ok','onClick="markOK()"','onClick="markOther()"');
  629.  
  630.     print "</form></body></html>";
  631. }
  632.     
  633. sub getAccounts {
  634.     undef (@dir); 
  635.     undef (@accounts);
  636.     undef (@type);
  637.     undef (@opt_string);
  638.  
  639.     open(IN, "< $conf");
  640.     while (<IN>) {
  641.         next if $_ eq "\n";
  642.         next if $_ =~ /^\s+#/;
  643.         @items = split(/\s+/);
  644.         push(@accounts, $items[0]);
  645.         push(@dir, $items[1]);
  646.         push(@type, $items[2]);
  647.         push(@opt_string, $items[3]);
  648.     }
  649.     close(IN);
  650. }
  651.  
  652. sub generic {
  653.     &js_title_block($title,$js_main);
  654.     &header_block($title);
  655.  
  656.     print "<i>$message</i>";
  657.  
  658.     print "<form name=AccountForm action=$myname method=post "
  659.         . "onSubmit=\"return runSubmit()\">";
  660.  
  661.     if ($delete) {
  662.         print "<input type=hidden name=\"delFile\" value=$name>\n";
  663.     }
  664.  
  665.     print "<table width=400><center>\n";
  666.         print "<tr><td><input type=submit name=\"add\" onClick=\"markAdd()\" \n"
  667.                 . "value=\"Add New $account_type_uc\"\n"
  668.                 . "</td><td><input name=\"new_account\" value=\"$val{'new_account'}\"\n"
  669.                 . "size=19 onClick=\"markAdd()\"></td></tr>\n";
  670.  
  671.         if ($#accounts >= 0) {
  672.                 if ($_[0]) {
  673.                         undef @show_accts;
  674.                         foreach $arg (@accounts) {
  675.                                 push(@show_accts, $arg) if $arg ne $_[0];
  676.                         }
  677.                         print "<input type=hidden name=deleted value=$_[0]>\n";
  678.                 } else { @show_accts = @accounts; }
  679.  
  680.                 print "<tr><td>\n"
  681.                         . "<input type=submit name=\"edit\" onClick=\"markEdit()\" \n"
  682.                         . "value=\"Edit Selected $account_type_uc\"></td><td rowspan=2>";
  683.                 print &choice_list(*show_accts, "chosen", 20);
  684.                 print "</td/tr>\n"
  685.                         . "<tr><td><input type=submit name=\"delete\" onClick=\"markDelete()\" \n"
  686.                         . "value=\"Delete Selected $account_type_uc\"></td></tr>\n";
  687.         }
  688.  
  689.         print "</table></center><br>";
  690.  
  691.     print &buttons('doit','Ok','onClick="markOK()"','onClick="markOther()"');
  692.  
  693.     print "</form></body></html>";
  694. }
  695.  
  696.